// WordDaoFactory.ts

import { LocalStorageWordDao } from "./LocalStorageWordDao";
import { TencentWordDao } from "./TencentWordDao";
import type { WordDao } from "./WordDao";

/**
 * WordDao工厂类，用于获取WordDao的实现
 */
export class WordDaoFactory {


  /**
   * 获取WordDao实例
   * @returns WordDao实现类的实例
   */
  public static getWordDao(): WordDao {
  
    let engine = localStorage.getItem('storageEngine');

    switch (engine) {
      case 'local':
        return new LocalStorageWordDao();
        case 'cloud':
        return new TencentWordDao();
      default:
        // 默认使用本地存储实现 
        return new LocalStorageWordDao();
    }

  }

  /**
   * 获取本地存储实现的WordDao实例
   * @returns LocalStorageWordDao实例
   */
  public static getLocalStorageWordDao(): WordDao {
    return new LocalStorageWordDao();
  }

  /**
   * 获取腾讯云实现的WordDao实例
   * @returns TencentWordDao实例
   */
  public static getTencentWordDao(): WordDao {
    return new TencentWordDao();
  }
}